from app_config import app, get_env

#直连数据库PGsql
from libs.DbUtils import DbUtils
DB_URI = 'postgresql+psycopg2://%s:%s@%s:%s/%s' % (
    get_env("PG_USER"), get_env("PG_PASSWORD"), get_env("ODOODBHOST"),
    get_env("ODOODBPORT"), get_env("ODOODBNAME"))

db_helper = DbUtils(DB_URI)

from flask_login import LoginManager
from flask_login import UserMixin

class User(UserMixin):
    user_dict={}
    def __init__(self,id,username):
        self.id = id
        self.username = username
        self.user_dict[self.id]=self


login_manager = LoginManager()
login_manager.init_app(app)

@login_manager.user_loader
def load_user(user_id):
        return User.user_dict.get(user_id,None)
from app_config import app
from flask import redirect
@app.route("/")
def index():
    return redirect("/library/logon")



